function e(e, a, t) {
    return a in e ? Object.defineProperty(e, a, {
        value: t,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[a] = t, e;
}

var a, t = getApp(), i = require("../../utils/icon.js"), s = require("../../utils/point.js");

Page({
    data: (a = {
        title: "",
        house: {},
        building: {},
        imgUrls: [ "http://fang-oss.haozu.com/cms/index/2018/04/17/sRS6YK6pM7.jpg@750w_490h_1e_1c" ],
        tjlist: [],
        houseNum: 0,
        mapUrl: "",
        tel_phone: "",
        total: 0,
        currIndex: 1,
        showYK: !1,
        shade: !1,
        subsucc: !1,
        hasError: !1,
        resPhone: "",
        isYK: !1,
        isDis: !1,
        isSC: !1,
        share: 0,
        shareimg: i.fenxiang,
        xingimg: i.xing,
        mapimg: i.mapimg,
        zhankai: i.zhankai,
        rightmore: i.rightmore,
        heart: i.heart,
        heart_red: i.heart_red,
        error_icon: i.error,
        close: i.close,
        isUp: !0,
        consultant: []
    }, e(a, "consultant", ""), e(a, "consultantA", ""), e(a, "consultantA", []), a),
    changeCur: function(e) {
        this.setData({
            currIndex: e.detail.current + 1
        });
    },
    onShareAppMessage: function(e) {
        var a = this;
        return {
            title: a.data.title,
            desc: a.data.title,
            path: "/pages/shareoffice/shareoffice?share=1&house_id=" + a.data.house.id
        };
    },
    shouchang: function(e) {
        var a = this, i = t.globalData.userInfo || {};
        if (t.globalData.userInfo) {
            var s = t.getSecret();
            a.data.isSC ? wx.request({
                url: t.globalData.uchaozuBase + "/api/miniapps/collect/del/",
                data: {
                    uid: i.user_id || "",
                    type: "2",
                    opt_id: a.data.house.id,
                    currtime: s.currtime,
                    sign: s.sign
                },
                success: function(e) {
                    e.data;
                    if (500 === e.statusCode) return !1;
                    a.setData({
                        isSC: !1
                    });
                }
            }) : wx.request({
                url: t.globalData.uchaozuBase + "/api/miniapps/collect/add/",
                data: {
                    uid: i.user_id || "",
                    type: "2",
                    opt_id: a.data.house.id,
                    currtime: s.currtime,
                    sign: s.sign
                },
                success: function(e) {
                    e.data;
                    if (500 === e.statusCode) return !1;
                    a.setData({
                        isSC: !0
                    });
                }
            });
        } else wx.setStorage({
            key: "HdataInfo",
            data: {
                uid: i.user_id || "",
                type: "2",
                opt_id: a.data.house.id
            }
        }), wx.navigateTo({
            url: "/pages/getinfo/index"
        });
    },
    toMapInfo: function() {
        var e = this.data.house, a = this.data.building;
        wx.navigateTo({
            url: "/pages/map/map?name=" + e.building_name + "&address=" + a.address + "&lat=" + a.lat + "&lng=" + a.lng
        });
    },
    onLoad: function(e) {
        var a = this;
        if (e.scene) {
            var i = decodeURIComponent(e.scene).split("&"), n = {
                type: i[0],
                id: i[1],
                phone: i[2]
            };
            e.house_id = n.id;
        }
        a.setData({
            share: e.share ? e.share : 0,
            tel_phone: t.globalData["tel-phone"]
        });
        var r = t.getSecret(), o = t.globalData.userInfo || {};
        o && o.mobile && a.setData({
            isDis: !0,
            resPhone: o.mobile
        }), wx.request({
            url: t.globalData.haozuBase + "/api/miniapps/house/",
            data: {
                house_id: e.house_id,
                mobile: o.mobile || "",
                user_guid: o.user_guid || "",
                currtime: r.currtime,
                sign: r.sign,
                uuid: wx.getStorageSync("first_code")
            },
            success: function(e) {
                var i = e.data;
                if (200 === i.code) {
                    var n = i.data.imageList, r = i.data.houseInfo;
                    i.data.employee_list, i.data.employee_list[0];
                    a.setData({
                        title: i.data.title,
                        house: r,
                        building: i.data.buildingInfo,
                        imgUrls: n,
                        houseNum: i.data.buildingHouseNumber,
                        total: n ? n.length : 0,
                        isYK: !!r.isIntention,
                        isSC: !!r.isCollect,
                        consultant: i.data.employee_list,
                        consultantA: i.data.employee_list[0]
                    });
                    var o = i.data.buildingInfo.lat, u = i.data.buildingInfo.lng;
                    s.getPoint({
                        lat: o,
                        lng: u
                    }).then(function(e) {
                        a.setData({
                            mapUrl: "http://apis.map.qq.com/ws/staticmap/v2/?center=" + e.lat + "," + e.lng + "&zoom=15&size=750*400&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:H|" + e.lat + "," + e.lng + "&key=" + t.globalData.tencentMapKey
                        });
                    }), t.orderDisabled(a, a.data.house.id, "house_id");
                    var l = {
                        id: "",
                        status: "",
                        circle_name: "",
                        district_name: "",
                        thumb_image: ""
                    };
                    for (var d in l) l[d] = r[d];
                    l.building_name = r.building_name, l.gongwei_number_min = r.gongwei_number_min, 
                    l.gongwei_number_max = r.gongwei_number_max, l.rent_price = r.avg_price, l.rent_price_unit = r.avg_price_unit, 
                    l.total_price = r.price, l.total_price_unit = r.price_unit, l.zhuangxiu = r.briefIntroduction.zhuangxiu.val, 
                    l.area = r.area, l.type = 2, console.log(l);
                    var c = {
                        t: 2,
                        v: r.id,
                        c: r.city_id,
                        d: r.district_id,
                        ci: r.circle_id,
                        s: r.street_id,
                        vt: new Date().getTime()
                    };
                    t.saveStorage(c, l), 1 == e.data.data.isCollect && a.setData({
                        isSC: !0
                    });
                }
            }
        });
    },
    showyekan: function(e) {
        this.setData({
            shade: !0,
            showYK: !0
        });
    },
    closeyuekan: function(e) {
        this.setData({
            shade: !1,
            showYK: !1
        });
    },
    inputChange: function(e) {
        this.setData({
            resPhone: e.detail.value
        });
    },
    submitYK: function(e) {
        var a = this, i = /^(13[0-9]|14[5|7]|15[0-9]|17[0|1|3|5|6|7|8]|18[0-9])\d{8}$/, s = a.data.resPhone;
        return !a.data.isYK && (i.test(s) ? (a.setData({
            hasError: !1
        }), void t.orderlogin({
            mobile: s,
            name: "小程序房源页预约",
            login: t.globalData.userInfo ? 0 : 1,
            house_id: a.data.house.id,
            building_name: a.data.house.building_name,
            from_page: 3
        }).then(function(e) {
            200 == e.code && (a.setData({
                showYK: !1,
                subsucc: !0,
                isYK: !0
            }), setTimeout(function() {
                a.setData({
                    shade: !1,
                    subsucc: !1
                });
            }, 3e3));
        })) : (a.setData({
            hasError: !0
        }), !1));
    },
    zixun: function(e) {
        console.log(this), wx.makePhoneCall({
            phoneNumber: e.currentTarget.dataset.phone
        });
    },
    zixunA: function() {
        wx.makePhoneCall({
            phoneNumber: this.data.consultantA.telephone
        });
    },
    showAll: function() {
        this.setData({
            isUp: !1
        });
    },
    xixika: function(e) {
        var a = [];
        a.push(e.currentTarget.dataset.id), wx.previewImage({
            current: e.currentTarget.dataset.id,
            urls: a
        });
    },
    zhizhao: function(e) {
        var a = [];
        a.push(e.currentTarget.dataset.id), wx.previewImage({
            current: e.currentTarget.dataset.id,
            urls: a
        });
    }
});